#
#
# major - minor - tag - ispatch 
#
__VERSION__ = (0, 2, 'rc', 0)
# check http://peak.telecommunity.com/DevCenter/setuptools#specifying-your-project-s-version
# Don't use - or any other character than . as a separator, 
# unless you really want a post-release. Remember that 2.1-rc2 means you've already released 2.1, 
#
#
def __get_version():
    """
        >>> from pkg_resources import parse_version as p
        >>> assert p('0.1dev-100') < p('0.1rc-100')
        >>> assert p('0.1rc-100') < p('0.2final')
        >>> assert p('0.2final-114') > p('0.2final')
    """
    def svn_version():
        import re
        entries_path = '%s/.svn/entries' % __path__[0]
        entries = open(entries_path, 'r').read()
        rev_match = re.search('\d+\s+dir\s+(\d+)', entries)
        if rev_match:
            return rev_match.groups()[0]
        return ""
    
    version = '%s.%s%s' % (__VERSION__[0], __VERSION__[1], __VERSION__[2])
    if __VERSION__[2] in ('dev','rc'):
        version = '%s.%s' % ( version, svn_version())
    elif __VERSION__[2] == 'final':
        if  __VERSION__[3] == 1:
            version = '%s-%s' % ( version, svn_version())

    return version

version = __get_version()


